<template>
	<view class="">
		<view class="u-p-20 u-flex u-flex-wrap">
			<view class="u-w-335 bg_FFFFFF u-m-l-10 u-m-r-10 u-m-b-20 u-b-r-16" v-for="(item,index) in list" :key="index" @click="$u.route(`/pages/home/paymassage?num=${item.spu}`)">
				<!-- <image src="" mode="aspectFit"></image> -->
				<u-image :src="item.imgs[0]" mode="aspectFit" width="335rpx" height='335rpx'>
				</u-image>
				<view class="u-p-20">
					<view class="cl_1C1C1CFF u-weight text-cut">{{item.name}}</view>
					<view class="u-p-t-20">
						<view class="u-flex">
							<u-image v-if="item.is_bjg==1" src="https://www.sqkjkj.vip/wxImg/common/home/img10.png" mode="aspectFill" width="68rpx"
								height='30rpx'></u-image>
							<view class="cl_FC3533FF u-font-30 u-weight">￥{{item.price}}</view>
						</view>
						<view class="u-m-t-10 u-text-right cl_848484FF u-font-24">已售{{item.sales}}</view>
					</view>
					<view class="u-flex  u-p-t-20">
						<u-image :src="item.shop_logo" mode="aspectFill" width="44rpx" height='44rpx'>
						</u-image>
						<view class="cl_848484FF u-m-l-10 u-font-20">{{item.shop_name}}</view>
					</view>
				</view>
			</view>
		</view>
		<u-loadmore :status="status" icon-type="circle" margin-bottom="20" />
		
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 商品数据
				params: {
					page: 1,
					page_size: 20,
					latitude: 34.793365,
					longitude: 113.599734,
				},
				list: [],
				status: 'loadmore',

			}
		},
		onLoad() {
			this.clear()
			this.like_goods()
		},
		onShow() {
		},
		// 下拉到底事件
		onReachBottom() {
			//避免多次触发
			if (this.status == 'loading' || this.status == 'nomore') {
				return;
			}
			this.like_goods();
		},
		methods: {
			clear() {
				this.list = [];
				this.params.page = 1;
			},
			like_goods(){
				this.$api.like_goods(this.params, res => {
					if(res.data.code==1){
						if (res.data.data.data.length < 20) {
							this.status = 'nomore';
						} else {
							this.params.page = this.params.page + 1;
							this.status = 'loadmore';
						}
						this.list = this.list.concat(res.data.data.data);
						uni.stopPullDownRefresh();
					}
				})
			}
		}
	}
</script>

<style scoped>
	page {
		background: #F5F5F5FF !important;
	}
</style>
